import React, { lazy } from 'react'

import NormalLayout from '@layout/NormalLayout';
import BasicLayout from '@layout/BasicLayout';

import {
    UserOutlined,
    // PieChartOutlined,
} from '@ant-design/icons';

/**
 * 最外层路由必须是 path:'/'和component, 自己配置第一层路由需要在children里写
 * 如有二级路由，需要在当前object结构里写入children里添加子路由
 * 在每层路由里加入 path:'*'和redirect:'/exception'，当路由不匹配时会自动跳转到这个异常页面，防止用户自己乱输路由进行匹配
 * @author swh
 */

export const store_routes = [
    {
        path: '/MyBoss/MyMenu',
        name: '我的菜单',
        icon: 'SnippetsOutlined',
        component: lazy(() => import('@pages/MyBoss/MyMenu'))
    },
    {
        path: '/MyBoss/DatStatistics',
        name: '数据统计',
        icon: 'SnippetsOutlined',
        component: lazy(() => import('@pages/MyBoss/DatStatistics'))
    },
    {
        path: '/MyBoss/MyOrder',
        name: '我的订单',
        icon: 'SnippetsOutlined',
        component: lazy(() => import('@pages/MyBoss/MyOrder'))
    },
    {
        path: '/MyClientMenu',
        name: '菜单浏览',
        icon: 'SnippetsOutlined',
        component: lazy(() => import('@pages/MyClientMenu'))
    },
    {
        path: '/PersonalCenter',
        name: '个人中心',
        icon: 'SnippetsOutlined',
        component: lazy(() => import('@pages/PersonalCenter'))
    },
    /**************用户配置相关************ */
    {
        path: '/RouteConfig',
        name: '路由配置',
        icon: 'ApartmentOutlined',
        component: 'RouteConfig'
    },
    {
        path: '/RoleConfig',
        name: '角色配置',
        icon: 'TeamOutlined',
        component: 'RoleConfig'
    },

    {
        path: '/AccountConfig',
        name: '用户配置',
        icon: 'UserOutlined',
        component: 'AccountConfig'
    },
    { path: '/', exact: true, redirect: '/MyBoss/MyMenu' },
    { path: '*', exact: true, redirect: '/exception' }
]

const getRouter = (routes) => {
    const router = [
        {
            path: '/',
            component: NormalLayout,
            children: [
                {
                    path: '/login',
                    name: 'app',
                    icon: "UserOutlined",
                    component: lazy(() => import('@pages/Home'))
                },
                {
                    // name: '异常页',
                    path: '/exception',
                    component: lazy(() => import('@component/NotFount'))
                },
                {
                    path: '/',
                    component: BasicLayout,
                    children: [
                        ...routes,
                        // ...store_routes
                    ]
                },

            ]
        }
    ]
    return router;
}


export default getRouter; 
